<template>
  <div ref="boxwrap" class="ProductFeaturesSecond">
    <div class="time-pick">
      <span>选择月份 </span>
      <el-date-picker
        v-model="month"
        type="month"
        placeholder="选择月份"
      />
    </div>
    <div class="main-content">
      <div class="box-wrap">
        <div class="title">产品特性</div>
        <div class="chart-wrap">
          <div><pie-chart id="widthspace-pie" height="100%" width="100%" title="线宽线距分布占比" /></div>
          <div><pie-chart id="size-pie" height="100%" width="100%" title="尺寸分布占比" /></div>
          <div><pie-chart id="thinkess-pie" height="100%" width="100%" title="铜厚分布占比" /></div>
          <div><pie-chart id="plant-pie" height="100%" width="100%" title="板厚分布占比" /></div>
        </div>
      </div>
      <div class="box-wrap">
        <div class="title">线宽线距</div>
        <div class="chart-wrap">
          <bar-chart id="widthspace" height="100%" width="100%" />
        </div>
      </div>
      <div class="box-wrap">
        <div class="title">cpk趋势图</div>
        <div class="chart-wrap">
          <line-chart id="cpkline" height="100%" width="100%" />
        </div>
      </div>
      <div class="box-wrap">
        <div class="title">cpk后四大料号分析</div>
        <div class="chart-wrap radar-charts">
          <div><radar-chart id="radar1" height="100%" width="100%" ctitle="料号1" /></div>
          <div><radar-chart id="radar2" height="100%" width="100%" ctitle="料号2" /></div>
          <div><radar-chart id="radar3" height="100%" width="100%" ctitle="料号3" /></div>
          <div><radar-chart id="radar4" height="100%" width="100%" ctitle="料号4" /></div>
        </div>
      </div>
      <div class="box-wrap">
        <!-- <div class="title">线宽线距cpk</div> -->
        <div ref="tablewrap" class="detail-table">
          <el-table :data="tableDataList" size="medium" border :height="tableHeight" :max-height="tableHeight">
            <el-table-column prop="partNum" label="料号" />
            <el-table-column prop="widthspace" label="线宽线距" />
            <el-table-column prop="size" label="尺寸" />
            <el-table-column prop="thinkess" label="铜厚" />
            <el-table-column prop="plant" label="板厚" />
            <el-table-column prop="cpk" label="cpk" />
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BarChart from './charts/features/Bar'
import LineChart from './charts/features/Line'
import PieChart from './charts/features/Pie'
import RadarChart from './charts/features/Radar'

export default {
  name: 'ProductFeaturesSecond',
  components: { BarChart, LineChart, PieChart, RadarChart },
  data() {
    return {
      month: '2021-08',
      tableHeight: 'auto',
      tableDataList: []
    }
  },
  mounted() {
    this.getDomStyle()
  },
  methods: {
    getDomStyle() {
      // this.$nextTick(() => {
      //   this.tableHeight = this.$refs.tablewrap.clientHeight - 5
      // })
      const that = this
      const dom = this.$refs.boxwrap
      this.$erd.listenTo(dom, function(element) {
        that.tableHeight = dom.clientHeight / 2 - 30
      })
    }
  }
}
</script>

<style lang="scss">
.ProductFeaturesSecond{
    width: 100%;
    height: 100%;

    .main-content{
      display: flex;
      flex-wrap: wrap;
      flex-direction: column;
      width: 100%;
      height: calc(100% - 46px);

      .box-wrap{
        width: calc(100% / 3);
        height: 50%;

        &:first-child{
          height: 100%;
          border-right: 1px solid #5967a4;

          .chart-wrap > div{
            height: 25%;
          }
        }

        &:nth-child(2n){
          border-bottom: 1px solid #5967a4;
        }

        &:nth-child(n+4){
          border-left: 1px solid #5967a4;
        }

        .title{
          margin-left: 20px;
          margin-top: 10px;
          color: #bebebe;
        }

        .chart-wrap{
          height: calc(100% - 30px);
        }

        .detail-table {
          width: 100%;
          height: calc(100% - 20px);
          padding-left: 10px;
          padding-top: 10px;
        }

        .radar-charts{
          display: flex;
          flex-wrap: wrap;

          > div{
            width: 50%;
            height: 50%;
            flex: auto;
          }
        }

      }
    }
}
</style>
